package cz.muni.fi.hauntedhouses.service.impl;

import cz.muni.fi.hauntedhouses.dao.GhostDAO;
import cz.muni.fi.hauntedhouses.service.GhostService;
import cz.muni.fi.hauntedhouses.to.GhostTO;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @author Andrea Vasekova, 325181
 */

@Service
@Transactional
public class GhostServiceImpl implements GhostService {
    
    @Autowired
    private GhostDAO dao;

    @Override
    @PreAuthorize("hasRole('ROLE_ADMIN')")
    public void create(GhostTO ghost) {
        dao.create(ghost);
    }

    @Override
    public GhostTO get(Long id) {
        
        return dao.get(id);
    }

    @Override
    @PreAuthorize("hasRole('ROLE_ADMIN')")
    public void update(GhostTO ghost) {
        dao.update(ghost);
    }

    @Override
    @PreAuthorize("hasRole('ROLE_ADMIN')")
    public void remove(GhostTO ghost) {
        dao.remove(ghost);
    }

    @Override
    public List<GhostTO> findAll() {
        return dao.findAll();
    }

    @Override
    public List<GhostTO> findByName(String name) {
        return dao.findByName(name);
    }
}
